<?php
// register the DataTable autoloader
include('/src/DataTable/Autoloader.php');
spl_autoload_register(array('DataTable_Autoloader', 'autoload'));

// include the Demo DataTable class
include_once('DemoDataTable.php');

// define the Browser Service to use for this demo
// either 'db' or 'csv'
define('SERVICE_TO_USE', 'db');
if(SERVICE_TO_USE == 'db'){
  
  include_once('DbBrowserService.php');
  $browserService = new DbBrowserService('localhost', 'instiny', 'root', '');
  
} elseif(SERVICE_TO_USE == 'csv'){
  
  include_once('CsvBrowserService.php');
  $browserService = new CsvBrowserService('data/browsers.csv');
}

// instatiate new DataTable
$table = new DemoDataTable();

// set selected Browser Service to the demo DataTable
$table->setBrowserService($browserService);

// convert DataTable AJAX parameters in request to a DataTable_Request
$request = new DataTable_Request();
$request->fromPhpRequest($_REQUEST);

// render the JSON data string
echo $table->renderJson($request);
